package com.csx.saas.platform.system.controller;

import com.csx.basic.base.R;
import com.csx.basic.base.controller.SuperCacheController;
import com.csx.saas.platform.system.dto.SystemRolePageQuery;
import com.csx.saas.platform.system.dto.SystemRoleSaveDTO;
import com.csx.saas.platform.system.dto.SystemRoleUpdateDTO;
import com.csx.saas.platform.system.entity.SystemRole;
import com.csx.saas.platform.system.service.SystemRoleService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * <p>
 * 前端控制器
 * 角色
 * </p>
 *
 * @author ChenSongXin
 * @date 2021-02-28
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/systemRole")
@Api(value = "SystemRole", tags = "角色")
//@PreAuth(replace = "platform:systemRole:")
public class SystemRoleController extends SuperCacheController<SystemRoleService, Long, SystemRole, SystemRolePageQuery, SystemRoleSaveDTO, SystemRoleUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SystemRole> systemRoleList = list.stream().map((map) -> {
            SystemRole systemRole = SystemRole.builder().build();
            //TODO 请在这里完成转换
            return systemRole;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(systemRoleList));
    }
}
